import * as React from 'react';
import { createElement, FC } from 'react';
import { Input } from 'antd';
import { BaseWrapper } from '../base';
import { useFormContainerSelector } from '../../form-container';

export interface FieldTextareaProps {
  max: string;
}

// 需要包一层 BaseWrapper 那边拿不到 componentName
const WarpComponent = (props) => {
  const { value, onChange, columnConfig } = props;
  const [readonly] = useFormContainerSelector((s) => [s.readonly]);
  return (
    <Input.TextArea
      disabled={readonly || columnConfig?.status === '2'}
      placeholder={columnConfig?.placeholder}
      defaultValue={columnConfig?.defaultValue}
      value={value}
      onChange={onChange}
    />
  );
};

export const FieldTextarea: FC<FieldTextareaProps> = (props) => {
  return (
    <BaseWrapper {...props}>
      <WarpComponent {...props}></WarpComponent>
    </BaseWrapper>
  );
};
